package dev.blogmoon.cn.system.enums;

import com.google.common.collect.Lists;

import java.util.List;

public enum FileTypeEnum {
    IMAGE(1, "图片","image/png","image/jpeg"),
    DOC(2, "文档",""),
    VIDEO(3, "视频","video/mp4"),
    AUDIO(4, "音频",""),
    OTHER(5, "其他",""),
    DIR(6,"文件夹","application/qiniu-object-manager");
    private Integer code;

    private List<String> name;
    private String desc;

    FileTypeEnum(Integer code, String desc,String... name) {
        this.code = code;
        this.name = Lists.newArrayList(name);
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public List<String> getName() {
        return name;
    }


    public static FileTypeEnum getByName(String name) {
        for (FileTypeEnum fileTypeEnum : FileTypeEnum.values()) {
            if (fileTypeEnum.getName().contains(name)) {
                return fileTypeEnum;
            }
        }
        return FileTypeEnum.OTHER;
    }

}
